Ext.define('PJ.view.parttrainingmanagement.List', {
    extend: 'AM.default.DefaultList',
    alias: ['widget.trainingManagementList'],
    requires: ['AM.default.DefaultSearchForm',
               'AM.default.DateTime', 
               'AM.default.DefaultDateField',
               'AM.default.DefaultDoubleDateField',
               'AM.default.jsonp.DefaultLoadJsonp',//jsonp加载数据
		       'AM.default.DefaultActiveStateCombo',
		       'PJ.view.quotamanagement.PlanPlacesList'//计划名额
               ],
               initComponent: function(){
               	var me= this;
               	this.columns = [{
               		header: '培训班编号',
               		dataIndex: 't.classNum',
               		width: 120,
               		renderer: function(value, meta, record){
               			meta.style = "white-space:normal;cursor: pointer;color:blue;";
               			meta.tdAttr = "data-qtip='" + value + "' classId=" + record.get("classId");
               			return value;
               		},
               		listeners: {
               			click: function(g, clm){
               				var classId = clm.getAttribute("classId");
               				win = Ext.create('PJ.view.trainingmanagement.Edit', {
               					title: "查看培训班",
               					flag:4,
               					grid: me,
               					isDisable:false,
               					isReadOnly:true,
               					classId:classId,
               					isHideExpectTime: false
               				}).show();
               				var actionName = "load";
               				if(gj_onlineLearning_constant.loadType == "jsonp"){
               					actionName = "loadJsonp";
               				}
               				win.down("form").getForm().doAction(actionName,{
               					url:me.store.preUpdateUrl,
               					params:{
               						classId: classId
               					},
               					success:function(f,action){
               						var data = action.response.responseText;
               	        			var json = gj_onlineLearning_constant.loadType=="ajax" ? Ext.decode(data, true) : action.response;
               	        			var form = win.down('form');	 
               	        			var baseForm = form.getForm();
               	        			baseForm.findField("classNum").setValue(json.data.classNum);
               	        			baseForm.findField("classNum_").setValue(json.data.classNum);
               					}
               				});

               			}
               		}
               	},{
                       header: '培训班名称',
                       dataIndex: 't.className',
                       flex: 1,
                       minWidth: 120,
               		renderer: function(value, metaData, record){
               			metaData.tdAttr = 'data-qtip="' + value + '"';
               			return value;
               		}
                   },{
                       header: '承办部委',
                       dataIndex: 't.ministrieName',
                       width: 120,
               		renderer: function(value, metaData, record){
               			metaData.tdAttr = 'data-qtip="' + value + '"';
               			return value;
               		}
                   },{
                       header: '开班时间',
                       dataIndex: 't.beginDate',
                       width: 80 
                   },{
                       header: '结业时间',
                       dataIndex: 't.endDate',
                       width: 80 
                   },{
                       header: '已报人数',     /*'已报人数/计划人数',*/
                       dataIndex: 'reportedNum',
                       width: 110,
                       sortable: false,
                       renderer: function(value, metaData, record){
                       	return value /*+ '/' + record.get('classUserNum')*/;
                       }
                   }/*,{
                       header: '提交状态',
                       dataIndex: 'reportState',
                       width: 70,
                       renderer: function(value, meta, record){
                           if(value==2){
                        	   return '<span style="color:red;">未提交</span>';
                           }else if(value==1){
                        	   return '<span style="color:green;">已提交</span>';
                           }
                        }
                   },{
                       header: '审核状态',
                       dataIndex: 'auditState',
                       renderer: function(v, metaData, record){
                           if (v == 2) {
                           	var auditReason = record.get('auditReason');
                   			metaData.tdAttr = 'data-qtip="' + auditReason + '"';
                               return '<span style="color:red;">' + '未审核通过' + '</span>';
                           }
                           else if(v == 1) {
                               return '<span style="color:green;">' + '审核通过' + '</span>';
                           }
                           else if(v == 3) {
                               return '未审核';
                           }
                       },
                       width: 80
                   }*/,{
                       header: '发布状态',
                       dataIndex: 't.publishState',
                       renderer: function(v, metaData, record){
                           if (v == 2) {
                               return '<span style="color:red;">' + '未发布' + '</span>';
                           }
                           else if(v == 1) {
                               return '<span style="color:green;">' + '已发布' + '</span>';
                           }
                       },
                       width: 70
                   },{
                       header: '班级状态',
                       dataIndex: 't.openState',
                       renderer: function(v, metaData, record){
                       	if(record.get("t.publishState") == 2){
                       		return '未开班';
                       	}else{
                       		if (v == 3) {
                                   return '<span style="color:red;">' + '已结班' + '</span>';
                               }
                               else if(v == 1) {
                                   return '<span style="color:green;">' + '已开班' + '</span>';
                               }
                               else if(v == 2) {
                                   return '未开班';
                               }
                       	}
                       },
                       width: 70
                   },{
                       header: '报名状态',
                       dataIndex: 't.signUpState',
                       renderer: function(v, metaData, record){
                       	if(record.get("t.publishState") == 2){
                       		return '<span style="color:red;">' + '未开始' + '</span>';
                       	}else if(record.get("t.publishState") == 1 && record.get("t.openState") == 1){
                       		return '<span style="color:red;">' + '报名结束' + '</span>';
                       	}else{
                       		if (v == 2) {
                                   return '<span style="color:red;">' + '未开始' + '</span>';
                               }
                               else if(v == 1) {
                                   return '<span style="color:green;">' + '正在报名' + '</span>';
                               }
                               else if(v == 3) {
                                   return '<span style="color:red;">' + '报名结束' + '</span>';
                               }
                       	}
                       },
                       width: 70
                   }/*, {
                   	header: '二维码',
                       dataIndex: 'registrationExplanation',
                       width: 65,
                       align: 'center',
                       renderer: function(value, metaData, record){
                       	metaData.tdAttr = 'classNum="' + record.get("q.classNum") + '" classId="' + record.get("classId") + '"';
                       	return '<span class="QRcodeIco" style="cursor: pointer;"></span> ';
                       },
                       listeners: {
           	            click: function(g, clm){
           	            	var classId = clm.getAttribute("classId");
           	            	var src = me.store.qrCodeUrl + "?classId=" + classId;
                       		Ext.create('AM.default.DefaultWindowView', {
                       			title: '二维码',
                       			width: 450,
                       			height: 550,
                       			grid: me,
                       			html: "<iframe src=\"" + src + "\" frameborder='0' style=\"width:100%;height:100%\"></iframe>",
                       			*
                       			items: [{
                       				html: '<div style="text-align: center;padding-top:10px;"><span color="#A9A9A9">' + subjectTitle + '</span></div><img src="./skin/red/images/QRcodegj.png" alt="二维码" style="width:255px;height:255px;padding:8px 20px 20px 20px;">'
                       			}],
                       			*
                       			buttons: [{
                       	            text: '关闭',
                       	            scope: this,
                       	            handler: function(button, event){
                       	                var win = button.up('window');
                       	                win.close();
                       	            }
                       	        }]
                       		}).show();
           	            }
                       }
                   }*/, {
                       header: '下载参训通知',
                       menuDisabled: true,
                       sortable: false,
                       resizable: false,
                       hideable: false,
                       xtype: 'actioncolumn',
                       width: 80,
                       items: [{
                       	//tooltip: '下载参训通知',
                       	getClass: function(v, meta, rec){
                       		var selectedLetters = rec.get('selectedLetters');
                       		if(!Ext.isEmpty(selectedLetters)){
                       			meta.style = "cursor: pointer;";
                           		return 'templateIco';
                       		}
                   		},
                           handler: function(grid, rowIndex, colIndex, item, eve, record){
                               var store = grid.getStore();
                               var atag = Ext.get("exportResume");
                               atag.set({
                                   "href": store.downloadUrl+'?attachmentID='+record.get('selectedLetters')
                               });
                               atag.dom.click();
                           }
                       }]
                   }];
               	
                   this.store = Ext.create('PJ.'+ prototype +'.trainingmanagement.List',{
                   	isLoad: true
                   });
                   this.callParent(arguments);
                   this.loadType = gj_onlineLearning_constant.loadType;//加载方式
               },
               //发送
           	onAddMsgClick:function(){
                   var me = this;
                   var record=me.getSelectionModel().getSelection();
               	var classId = record[0].get("classId");
               	var className = record[0].get("t.className");
           		if(this.getSelectionModel().getCount() > 1){
                       Ext.Msg.show({
                           title: '提示',
                           msg: '操作时只可选中一条记录！',
                           icon: Ext.Msg.WARNING,
                           buttons: Ext.Msg.OK
                       });
                   	return;
                   }
           		win = Ext.create('PJ.view.messagemanagement.Edit', {
                   	title: "新增发送消息",
                   	width: 520,
                   	height:330,
                   	typeCode:1,
                   	classId:classId,
                   	flagStr:"class",
                   	grid: me
                   }).show();
           		win.down('panel').getForm().findField("defaultValue").setValue(className);
           		win.down('panel').getForm().findField("newsTypeCode").setValue("xxlx_pxb");
               },
           	//新增
           	onAddClick:function(){
                   var me = this;
                   Ext.create('PJ.view.trainingmanagement.Edit',{
                   	title: "新增培训班",
                       flag:1,
                   	grid: me,
                   	isDisable:true,
                   	isReadOnly:false
                   });
               },
           	//修改
           	onUpdateClick:function(){
           		var me = this;
           		var record=me.getSelectionModel().getSelection();
               	var classId = record[0].get("classId");
           		if(this.getSelectionModel().getCount() > 1){
                       Ext.Msg.show({
                           title: '提示',
                           msg: '操作时只可选中一条记录！',
                           icon: Ext.Msg.WARNING,
                           buttons: Ext.Msg.OK
                       });
                   	return;
                   }
           		if(record[0].get("t.publishState")==1){
           			Ext.Msg.show({
                           title: '提示',
                           msg: '已发布的信息不允许再进行修改操作!',
                           icon: Ext.Msg.WARNING,
                           buttons: Ext.Msg.OK
                       });
                   	return;
           		}
                   win = Ext.create('PJ.view.trainingmanagement.Edit', {
                   	title: "更新培训班",
                       flag:2,
                   	grid: me,
                   	isDisable:true,
                   	classId:classId,
                   	isReadOnly:false
                   }).show();
           		var actionName = "load";
           		if(gj_onlineLearning_constant.loadType == "jsonp"){
           			actionName = "loadJsonp";
           		}
           		win.down("form").getForm().doAction(actionName,{
               		url:me.store.preUpdateUrl,
               		params:{
               			classId: classId
               		},
               		success:function(f,action){
               			var data = action.response.responseText;
               			var json = gj_onlineLearning_constant.loadType=="ajax" ? Ext.decode(data, true) : action.response;
               			var form = win.down('form');	 
               			var baseForm = form.getForm();
               			baseForm.findField("classNum").setValue(json.data.classNum);
               			baseForm.findField("classNum_").setValue(json.data.classNum);
               		}
               	});
           	},
               //配置课程
               onConfigurationClick: function(button){
               	var me = this;
                   var records = me.getSelectionModel().getSelection();
                   if (button.up("grid").getSelectionModel().getCount() > 1) {
                       Ext.Msg.show({
                           title: '警告',
                           msg: '操作时只可选中一条记录！',
                           icon: Ext.Msg.WARNING,
                           buttons: Ext.Msg.OK
                       });
                       return;
                   }else {
                   	win = Ext.create('PJ.view.trainingmanagement.ConfigurationCourseEdit',{
                       	title: "配置课程",
                       	grid: me,
                       	classId: records[0].get("classId")
                       }).show();
               		var actionName = "load";//默认使用非JSONP的加载方法名“load”
                       if(gj_onlineLearning_constant.loadType=="jsonp") {
                       	actionName= "loadJsonp";
                       }
                       win.down('form').getForm().doAction(actionName,{
                       	url: me.store.preUpdateUrl,
                           params: {
                           	classId: records[0].get("classId")//培训班ID
                           },
                           success:function(form,action){
                           	var data = action.response.responseText;
                   			var json = gj_onlineLearning_constant.loadType=="ajax" ? Ext.decode(data, true) : action.response;
                   			var dateStar = json.data.beginDateStr;//举办时间（开始）
                   			var dateEnd = json.data.endDateStr;//举办时间（截止）
                   			var form = win.down('form');	 
                   			var baseForm = form.getForm();
                   			baseForm.findField("learnTime").setValue(dateStar + ' 至 ' + dateEnd);
                           }
                       });
                   }
               },
           	//删除
           	onDeleteClick:function(){
             	  var me = this;
             	  var store = me.getStore();
             	  var records = me.getSelectionModel().getSelection();
             	  for(var i=0;i<records.length;i++){
             		  if(records[i].get("t.publishState")==1){
             			Ext.Msg.show({
             				  title: '提示',
             			  	  msg  : '不允许删除已发布的数据！',
             			  	  icon :Ext.Msg.WARNING,
             			  	  buttons:Ext.Msg.OK
             			  });
             			  return;
             		  }
             	  };
             	Ext.Msg.confirm({
           		  title:'提示',
           		  msg:'您确定要删除这些数据吗?',
           		  icon:Ext.Msg.WARNING,
           		  buttons:Ext.Msg.OKCANCEL,
           		  fn:function(id){
           			  if(id=='ok'){
           				  var classIds= new Array();
           				  Ext.Array.each(records,function(name,index){
           					  classIds.push(name.get('classId'));
           				  });
           				  if(gj_onlineLearning_constant.loadType == "jsonp"){
           					  var store1 = Ext.create('AM.default.jsonp.DefaultAjaxStore',{
                             		loadType: gj_onlineLearning_constant.loadType,
                                     url: store.deleteUrl,
                             		  extraParams: {
                             			searchUpdateClassIds: classIds,
           							  submintType: 'activeStateToN'
                                     }
                             	});
                             	store1.load(function(rec, operation, success){
                             		if(success){
                                         Ext.Msg.alert('消息', '删除成功！', function(){
                                             var store = me.getStore();
                                             store.load();
                                         });
                                     }else{
                                         Ext.Msg.alert('消息', operation.error);
                                     }
                             	});
           				  }else{
           					  Ext.Ajax.request({
           						  url:store.deleteUrl,
           						  params: {
           							  searchUpdateClassIds: classIds,
           							  submintType: 'activeStateToN'
           	                       },
           						  success:function(response){
           							  var data=response.responseText;
           							  var json=Ext.decode(data,true);
           							  if(json.success){
           								  Orchid.alert('提示','删除成功!',function(){
           									  store.load();
           								  });
           							  }else{
           								  Orchid.alert('提示',json.msg);
           							  }
           						  }
           					  });
           				  }
           			  }
           		  }
           	  });
           	},
           	//发布
           	onIssueClick:function(){
             	  var me=this;
             	  var store=me.getStore();
             	  var records=me.getSelectionModel().getSelection();
             	  for(var i=0;i<records.length;i++){
             		  if(records[i].get("t.publishState")==1){
             			Ext.Msg.show({
             				  title: '提示',
             			  	  msg  : '已发布的班级不能再次发布!',
             			  	  icon :Ext.Msg.WARNING,
             			  	  buttons:Ext.Msg.OK
             			  });
             			  return;
             		  }
             		/*  if(records[i].get("auditState")!=1){
             			Ext.Msg.show({
           				  title: '提示',
           			  	  msg  : '只允许对审核通过的数据进行发布!',
           			  	  icon :Ext.Msg.WARNING,
           			  	  buttons:Ext.Msg.OK
           			  });
           			  return;
             		  }*/
             	  };
             	Ext.Msg.confirm({
           		  title:'提示',
           		  msg:'您确定要发布这些数据吗?',
           		  icon:Ext.Msg.WARNING,
           		  buttons:Ext.Msg.OKCANCEL,
           		  fn:function(id){
           			  if(id=='ok'){
           				  var classIds= new Array();
           				  Ext.Array.each(records,function(name,index){
           					  classIds.push(name.get('classId'));
           				  });
           				  if(gj_onlineLearning_constant.loadType == "jsonp"){
           					  var store1 = Ext.create('AM.default.jsonp.DefaultAjaxStore',{
                             		loadType: gj_onlineLearning_constant.loadType,
                                     url: store.issueUrl,
                             		  extraParams: {
                             			searchUpdateClassIds: classIds,
                             			submintType: 'publishStateToY'
                                     }
                             	});
                             	store1.load(function(rec, operation, success){
                             		if(success){
                                         Ext.Msg.alert('消息', '发布成功！', function(){
                                             var store = me.getStore();
                                             store.load();
                                         });
                                     }else{
                                         Ext.Msg.alert('消息', operation.error);
                                     }
                             	});
           				  }else{
           					  Ext.Ajax.request({
           						  url:store.issueUrl,
           						  params: {
           	                  			searchUpdateClassIds: classIds,
           	                  			submintType: 'publishStateToY'
           						  },
           						  success:function(response){
           							  var data=response.responseText;
           							  var json=Ext.decode(data,true);
           							  if(json.success){
           								  Orchid.alert('提示','发布成功!',function(){
           									  store.load();
           								  });
           							  }else{
           								  Orchid.alert('提示',json.msg);
           							  }
           						  }
           					  });
           				  }
           			  }
           		  }
           	  });
           	},
           	//撤销发布
           	onIssuenoClick:function(){
           		var me=this;
           		var store=me.getStore();
           		var records=me.getSelectionModel().getSelection();
           		for(var i=0;i<records.length;i++){
           			if(records[i].get("t.openState") ==3){
           				Ext.Msg.show({
           					title: '提示',
           					msg  : '不允许对已结班的数据执行撤销发布操作!',
           					icon :Ext.Msg.WARNING,
           					buttons:Ext.Msg.OK
           				});
           				return;
           			}
           			if(records[i].get("t.publishState")==2){
           				Ext.Msg.show({
           					title: '提示',
           					msg  : '不允许未发布的数据执行撤销发布操作!',
           					icon :Ext.Msg.WARNING,
           					buttons:Ext.Msg.OK
           				});
           				return;
           			}
           		};
           		Ext.Msg.confirm({
           			title:'提示',
           			msg:'您确定要撤销这些数据吗?',
           			icon:Ext.Msg.WARNING,
           			buttons:Ext.Msg.OKCANCEL,
           			fn:function(id){
           				if(id=='ok'){
           					var classIds= new Array();
           					Ext.Array.each(records,function(name,index){
           						classIds.push(name.get('classId'));
           					});
           					if(gj_onlineLearning_constant.loadType == "jsonp"){
           						var store1 = Ext.create('AM.default.jsonp.DefaultAjaxStore',{
           							loadType: gj_onlineLearning_constant.loadType,
           							url: store.noIssueUrl,
           							extraParams: {
           	                  			searchUpdateClassIds: classIds,
           	                  			submintType: 'publishStateToN'
           							}
           						});
           						store1.load(function(rec, operation, success){
           							if(success){
           								Ext.Msg.alert('消息', '撤销成功!', function(){
           									var store = me.getStore();
           									store.load();
           								});
           							}else{
           								Ext.Msg.alert('消息', operation.error);
           							}
           						});
           					}else{
           						Ext.Ajax.request({
           							url:store.noIssueUrl,
           							params: {
           	                  			searchUpdateClassIds: classIds,
           	                  			submintType: 'publishStateToN'
           							},
           							success:function(response){
           								var data=response.responseText;
           								var json=Ext.decode(data,true);
           								if(json.success){
           									Orchid.alert('提示','撤销成功!',function(){
           										store.load();
           									});
           								}else{
           									Orchid.alert('提示',json.msg);
           								}
           							}
           						});
           					}
           				}
           			}
           		});
           	},
           	//审核通过
           	onApprovalClick: function(){
           		var me=this;
           		var store=me.getStore();
           		var records=me.getSelectionModel().getSelection();
           		for(var i=0;i<records.length;i++){
           			if(records[i].get("auditState")==1){
           				Ext.Msg.show({
           					title: '提示',
           					msg  : '不允许审核通过的数据再次执行审核通过操作!',
           					icon :Ext.Msg.WARNING,
           					buttons:Ext.Msg.OK
           				});
           				return;
           			}
           			if(records[i].get("reportState")==2){
           				Ext.Msg.show({
           					title: '提示',
           					msg  : '不允许对未提交的数据执行审核通过操作!',
           					icon :Ext.Msg.WARNING,
           					buttons:Ext.Msg.OK
           				});
           				return;
           			}
           		};
           		Ext.Msg.confirm({
           			title:'提示',
           			msg:'您确定这些数据审核已通过吗?',
           			icon:Ext.Msg.WARNING,
           			buttons:Ext.Msg.OKCANCEL,
           			fn:function(id){
           				if(id=='ok'){
           					var classIds= new Array();
           					Ext.Array.each(records,function(name,index){
           						classIds.push(name.get('classId'));
           					});
           					if(gj_onlineLearning_constant.loadType == "jsonp"){
           						var store1 = Ext.create('AM.default.jsonp.DefaultAjaxStore',{
           							loadType: gj_onlineLearning_constant.loadType,
           							url: store.reuseUrl,
           							extraParams: {
           								searchUpdateClassIds: classIds,
           								submintType: 'auditClassStateToY'
           							}
           						});
           						store1.load(function(rec, operation, success){
           							if(success){
           								Ext.Msg.alert('消息', '审核成功!', function(){
           									var store = me.getStore();
           									store.load();
           								});
           							}else{
           								Ext.Msg.alert('消息', operation.error);
           							}
           						});
           					}else{
           						Ext.Ajax.request({
           							url:store.reuseUrl,
           							params: {
           								searchUpdateClassIds: classIds,
           								submintType: 'auditClassStateToY'
           							},
           							success:function(response){
           								var data=response.responseText;
           								var json=Ext.decode(data,true);
           								if(json.success){
           									Orchid.alert('提示','审核成功!',function(){
           										store.load();
           									});
           								}else{
           									Orchid.alert('提示',json.msg);
           								}
           							}
           						});
           					}
           				}
           			}
           		});
           	},
           	//审核驳回
           	onDismissedClick: function(){
           		var me=this;
           		var store=me.getStore();
           		var records=me.getSelectionModel().getSelection();
           		var classIds= new Array();
           		Ext.Array.each(records,function(name,index){
           			classIds.push(name.get('classId'));
           		});
           		for(var i=0;i<records.length;i++){
           			if(records[i].get("reportState")==2){
           				Ext.Msg.show({
           					title: '提示',
           					msg  : '不允许对未提交的数据执行审核通过操作!',
           					icon :Ext.Msg.WARNING,
           					buttons:Ext.Msg.OK
           				});
           				return;
           			}
           			if(records[i].get("auditState")==2){
           				Ext.Msg.show({
           					title: '提示',
           					msg  : '不允许对未审核通过的数据执行审核驳回操作!',
           					icon :Ext.Msg.WARNING,
           					buttons:Ext.Msg.OK
           				});
           				return;
           			}
           			if(records[i].get("t.publishState")==1){
           				Ext.Msg.show({
           					title: '提示',
           					msg  : '不允许对已发布的数据执行审核驳回操作！',
           					icon :Ext.Msg.WARNING,
           					buttons:Ext.Msg.OK
           				});
           				return;
           			}
           		};
           		Ext.create('PJ.view.trainingmanagement.CheckEdit',{
                   	title: "审核驳回原因",
                       flag:1,
                       classIds: classIds,
                   	grid: me
                   });
           	},
           	//上传参训通知
           	onImportClick: function(){
           		var me = this;
           		var records = me.getSelectionModel().getSelection();
           		if(records.length > 1){
           			Ext.Msg.show({
           				title: '提示',
           				msg: '只允许操作一条数据！',
           				icon: Ext.Msg.WARNING,
           				buttons: Ext.Msg.OK
           			});
           			return;
           		}
           		Ext.create("PJ.view.trainingmanagement.Upload", {
           			title: "上传参训通知",
           			height: 140,
           			width: 350,
           			grid: me,
           			classId: records[0].get('classId')
           		}).show();
//               	Ext.create("PJ.view.trainingmanagement.UploadInfo", {
//           			title: "上传参训通知",
//           			height: 140,
//           			width: 350,
//           			grid: me,
//           			classId: records[0].get('classId')
//           		}).show();
               },
               //导出 -- 判断按钮是否可以操作
               ifSelect: function(selectType, exportUrl, classId, urlExportId){
               	var records = this.getSelectionModel().getSelection();
               	if(selectType=='course'){
               		if(records.length == 0){
               			Ext.Msg.show({
               				title: '提示',
               				msg: '请选择一条数据进行操作！',
               				icon: Ext.Msg.WARNING,
               				buttons: Ext.Msg.OK
               			});
               			return;
               		}
               		if(records.length > 1){
               			Ext.Msg.show({
               				title: '提示',
               				msg: '只允许操作一条数据！',
               				icon: Ext.Msg.WARNING,
               				buttons: Ext.Msg.OK
               			});
               			return;
               		}
               	}
                   var atag = Ext.get("exportResume");
                   var exportUrlStr = Ext.isEmpty(urlExportId)?exportUrl:exportUrl + '?'+ urlExportId + '=' + classId;
               	atag.set({
               		"href": exportUrlStr
               	});
                   atag.dom.click();
               
               },
             /*//导入名额
               onImportquotasClick: function(){
           		var me = this;
               	Ext.create("PJ.view.quotamanagement.BatchImportEdit", {
           			title: "导入名额",
           			height: 110,
           			width: 380,
           			grid: me
           		}).show();
               },*/
               /**
                * 计划名额
                */
               onPlanplacesClick: function(){
           		var me = this;
           		var record = this.getSelectionModel().getSelection();
                   if(this.getSelectionModel().getCount() > 1){
                       Ext.Msg.show({
                           title: '提示',
                           msg: '操作时只可选中一条记录！',
                           icon: Ext.Msg.WARNING,
                           buttons: Ext.Msg.OK
                       });
                   	return;
                   }
           		Ext.create('AM.default.DefaultWindowView', {
                       title: record[0].get("t.className"),
                       height:550,
                       width: 450,
                       grid: me,
                       classId:record[0].get("classId"),
                       items: [{
                           xtype: 'planPlacesList'
                       }],
                       listeners: {
                       	close: function(){
                       		me.getStore().load();
                       	}
                       }
                   });
           	},
               //预览
               listeners: {
           		selectionchange: function(selModel, selected){
           			this.down('#' + this.oldId + "Configuration").setDisabled(selected.length === 0);//配置课程
           			this.down('#' + this.oldId + "Issue").setDisabled(selected.length === 0);//发布
                      this.down('#' + this.oldId + "Issueno").setDisabled(selected.length === 0);//撤销发布
                       this.down('#' + this.oldId + "Delete").setDisabled(selected.length === 0);//删除
//                       this.down('#' + this.oldId + "Dismissed ").setDisabled(selected.length === 0);//审核驳回
//                       this.down('#' + this.oldId + "Approval").setDisabled(selected.length === 0);//审核通过
                       this.down('#' + this.oldId + "BatchImportRegistration").setDisabled(selected.length === 0);//上传参训通知
             //          this.down('#' + this.oldId + "Planplaces").setDisabled(selected.length === 0);//计划名额
            //           this.down('#' + this.oldId + "AddMsg").setDisabled(selected.length === 0);//发送消息
           		},
           		viewready: function(){
           			var me = this;
           			//导出按钮集合
                   	var exportMenu = Ext.create('Ext.menu.Menu', {
                           items: [{
                               text: '培训班',
           	        		iconCls: 'classIco',
                               listeners: {
                                   click: function(btn){
                                   	var records = me.getSelectionModel().getSelection();
                                   	//me.ifSelect('class', me.store.exportTrainingUrl);
                                   	
                                       var classIdstr = "";
                                       for(var i = 0;i<records.length;i++){
                                       	if(i == records.length-1){
                                       		classIdstr += "searchClassIdList=" + records[i].get("classId");
                                       	}else{
                                       		classIdstr += "searchClassIdList=" + records[i].get("classId") + "&";
                                       	}
                                       }
                                       var atag = Ext.get("exportResume");
                                       var exportUrl = me.store.exportTrainingUrl;
                                       atag.set({
                                           "href": exportUrl + '?' + classIdstr
                                       });
                                       atag.dom.click();
                               	}
                               }
                           }, {
                               text: '课程',
           	        		iconCls: 'courseIco',
                               listeners: {
                               	click: function(btn){
                                   	var record = me.getSelectionModel().getSelection();
                                   	var classId = Ext.isEmpty(record) ? "" : record[0].get("classId");
                                   	me.ifSelect('course', me.store.exportCourseUrl, classId, 'searchClassId');
                               	}
                               }
                           }, {
                               text: '班级详情',
           	        		iconCls: 'classDetailsIco',
                               listeners: {
                               	click: function(btn){
                                   	var records = me.getSelectionModel().getSelection();
                                       var classIds = new Array();
                                       Ext.Array.each(records, function(name, index){
                                       	classIds.push(name.get("classId"));
                                       });
                                   	if(records.length == 0){
                               			Ext.Msg.show({
                               				title: '提示',
                               				msg: '请选择所需数据进行操作！',
                               				icon: Ext.Msg.WARNING,
                               				buttons: Ext.Msg.OK
                               			});
                               			return;
                               		}else if(records.length > 1){
                               			Ext.Msg.show({
                               				title: '提示',
                               				msg: '班级详情只可以选取一条数据！',
                               				icon: Ext.Msg.WARNING,
                               				buttons: Ext.Msg.OK
                               			});
                               			return;
                               		}else{
                               			var atag = Ext.get("exportResume");
                                           var exportUrl = me.store.exportClassInfoUrl;
                                           atag.set({
                                               "href": exportUrl + '?searchClassIds=' + classIds
                                           });
                                           atag.dom.click();
                               		}
                               	}
                               }
                           }/*, {
                               text: '名额对比表',
           	        		iconCls: 'comparisonsIco',
                               listeners: {
                               	click: function(btn){
                               		var records = me.getSelectionModel().getSelection();
                                   	//var classId = Ext.isEmpty(record) ? "" : record[0].get("classId");
                                   	//me.ifSelect('comparisons', me.store.contrastPlacesUrl, classId, 'searchClassId');
                                   	var classIdstr = "";
                                       for(var i = 0;i<records.length;i++){
                                       	if(i == records.length-1){
                                       		classIdstr += "searchClassIds=" + records[i].get("classId");
                                       	}else{
                                       		classIdstr += "searchClassIds=" + records[i].get("classId") + "&";
                                       	}
                                       }
                                       var atag = Ext.get("exportResume");
                                       var exportUrl = me.store.contrastPlacesUrl;
                                       atag.set({
                                           "href": exportUrl + '?' + classIdstr
                                       });
                                       atag.dom.click();
                               	}
                               }
                           }*/]
                       });
           			this.addDocked([{
           				dock: 'top',
           				xtype: "searchform",
           				columnCount: 3,
           				fieldDefaults: {
           					labelAlign: 'right',
           					labelWidth: 100
           				},
           				items: [{
           					xtype: "textfield",
           					fieldLabel: '培训班编号',
           					name: "searchTrainingNum",
           					maxLength: "50",
           					emptyText: "请输入培训班编号"
           				},{
           					xtype: "textfield",
           					fieldLabel: '培训班名称',
           					name: "searchClassName",
           					maxLength: "50",
           					emptyText: "请输入培训班名称"
           				},{
           					xtype: "textfield",
           					fieldLabel: '承办部委',
           					name: "searchMinistrieName",
           					maxLength: "50",
           					emptyText: "请输入承办部委"
           				}, {
               				xtype: 'defaultDate',
               				fieldLabel: '开班时间',
               				name: 'searchBeginDate',
               				id: 'searchTrainingManagementSD',
               				vtype: 'startLessEndDate',
               				startLessEndDate: {
               					targetCmpId: 'searchTrainingManagementED',
               					isStart: true
               				},
               				emptyText: "请输入开班时间"
               			}, {
               				xtype: 'defaultDate',
               				fieldLabel: '结业时间',
               				labelSeparator: '',
               				name: 'searchEndDate',
               				id: 'searchTrainingManagementED',
               				vtype: 'startLessEndDate',
               				vtypeText: '结束时间不能早于开始时间！',
               				startLessEndDate: {
               					targetCmpId: 'searchTrainingManagementSD',
               					isStart: false
               				},
               				emptyText: "请输入结业时间"
               			}/*,{
           					xtype: "combo",
           					fieldLabel: '审核状态',
           					name: "searchAuditState",
           					store: Ext.create("Ext.data.ArrayStore", {
           						fields: ['value', 'text'],
           						data: [[1, '审核通过'],[2,'未审核通过'],[3,'未审核']]
           					}),
           					valueField: 'value',
           					displayField: 'text',
           					editable: false,
           					emptyText: "请选择"
           				}*/,{
           					xtype: "combo",
           					fieldLabel: '班级状态',
           					name: "searchOpenState",
           					store: Ext.create("Ext.data.ArrayStore", {
           						fields: ['value', 'text'],
           						data: [[1, '已开班'],[2,'未开班'],[3,'已结班']]
           					}),
           					valueField: 'value',
           					displayField: 'text',
           					editable: false,
           					emptyText: "请选择"
           				},{
           					xtype: "combo",
           					fieldLabel: '发布状态',
           					name: "searchPublishState",
           					store: Ext.create("Ext.data.ArrayStore", {
           						fields: ['value', 'text'],
           						data: [[1, '已发布'],[2,'未发布']]
           					}),
           					valueField: 'value',
           					displayField: 'text',
           					editable: false,
           					emptyText: "请选择"
           				},{
           					xtype: "combo",
           					fieldLabel: '报名状态',
           					name: "searchSignUpState",
           					store: Ext.create("Ext.data.ArrayStore", {
           						fields: ['value', 'text'],
           						data: [[1, '正在报名'],[2,'未开始'],[3,'报名结束']]
           					}),
           					valueField: 'value',
           					displayField: 'text',
           					editable: false,
           					emptyText: "请选择"
           				}],
           				grid: this
           			},{
           				xtype: 'toolbar',
           				dock: 'top',
           				displayInfo: true,
           				items: [this.addButton, "-", this.updateButton, "-", {
           					text: '删除',
           					iconCls: 'deleteIco',
           					itemId: this.oldId + "Delete",
           					disabled: true,
           					scope: this,
           					handler: this.onDeleteClick
           				}, "-",{
           					text: '发布',
           					iconCls: 'publishIco',
           					itemId: this.oldId + "Issue",
           					disabled: true,
           					scope: this,
           					handler: this.onIssueClick
           				}, "-", {
           					text: '撤销发布',
           					iconCls: 'publishCancelIco',
           					itemId: this.oldId + "Issueno",
           					disabled: true,
           					scope: this,
           					handler: this.onIssuenoClick
           				},"-",/*{
           					text: '导入名额',
           					iconCls: 'batchImportRegistrationIco',
           					itemId: this.oldId + "Importquotas",
           					disabled: false,
           					scope: this,
           					handler: this.onImportquotasClick
           				},"-", {
           					text: '查看计划名额',
           					iconCls: 'planplacesIco',
           					itemId: this.oldId + "Planplaces",
           					disabled: true,
           					scope: this,
           					handler: this.onPlanplacesClick
           				},"-",{
           					text: '发送消息',
           					iconCls: 'addIco',
           					itemId: this.oldId + "AddMsg",
           					disabled: true,
           					scope: this,
           					handler: this.onAddMsgClick
           				},"-",{
                               text: '配置课程',
                               iconCls: 'configIco',
                               itemId: this.oldId + "Configuration",
                               disabled: true,
                               scope: this,
                               handler: this.onConfigurationClick
                           },"-", {
           					text: '审核通过',
           					iconCls: 'examinationPassedIco',
           					itemId: this.oldId + "Approval",
           					disabled: true,
           					scope: this,
           					handler: this.onApprovalClick
           				},"-",{
           					text: '审核驳回',
           					iconCls:'auditDismissedIco',
           					itemId: this.oldId + "Dismissed",
           					disabled: true,
           					scope: this,
           					handler:this.onDismissedClick
           				},*/
           				{
                            text: '上传参训通知',
                            iconCls: 'batchImportRegistrationIco',
                            itemId: this.oldId + "BatchImportRegistration",
                            disabled: true,
                            scope: this,
                            handler: this.onImportClick
        				},"-",{
                               text: '配置课程',
                               iconCls: 'configIco',
                               itemId: this.oldId + "Configuration",
                               disabled: true,
                               scope: this,
                               handler: this.onConfigurationClick
                           },"-",{
                               text: '导出',
                           	xtype: 'button',
                               cls: 'floater',
                               textAlign: 'right',
                               arrowAlign: 'right',
                               itemId: this.oldId + 'Export',
                               enableToggle: true,
                               iconAlign: 'left',
                               iconCls: 'deriveIco',
                               pressedCls: 'x-btn-focus',
                               menuActiveCls: 'x-btn-menu-active',
                               menu: exportMenu
           				},"->", this.countSelectPanel]
           			}]);
                       // 触发权限过滤事件
                       me.fireEvent("permission", this);
           		}
               }
           });

